package name.ekr.assetguide.data;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class FileDataLogger implements DataLogger {

	private String fileName;
	private PrintWriter writer;
	
	public FileDataLogger(String fileName) {
		this.fileName = fileName;
	}

	@Override
	public void info(String data) throws IOException {
		writer.println(data);
	}

	@Override
	public void open() throws IOException {
		writer = new PrintWriter(
					new BufferedWriter(
					new OutputStreamWriter(
					new FileOutputStream(fileName))));
		//writer.println("profit;risk;portfolio;type");
        writer.println("profit;risk;USD;GLD;SLV;SHR;BND;RUR;type");
	}

	@Override
	public void close() throws IOException {
		writer.flush();
		writer.close();
	}

}
